<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------
// 应用公共文件
use think\Db;

//字符串格式验证
function check_format($str1, $str2)
{
    // $str1:匹配字符串
    // $str2:正则表达式
    if (preg_match($str2, $str1)) {
        //匹配成功
        return true;
    } else {
        //匹配失败
        return false;
    }
}
//判断数组字段是否传入
function check_array($data,$name){
    foreach($name as $v){
        if(!isset($data[''.$v.''])){
            return array('code' => -3, 'msg' => '请传输字段：'.$v, 'data' => array());
        }
    }
    return array('code' => 1, 'msg' => '验证成功', 'data' => array());
}

